package com.lin.manager.secure.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.Set;

/**
 * @作者: 林江
 * @创建时间: 2024/3/15
 * @功能:
 */
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SecurityUser implements UserDetails {
    private Long id;
    private String password;
    private String username;
    private String name;
    private String phone;
    private Integer status;
    /*权限*/
    private Set<GrantedAuthority> authorities;
    /*账户是否过期*/
    private boolean accountNonExpired;
    /*账户是否锁定*/
    private boolean accountNonLocked;
    /*凭证是否过期*/
    private boolean credentialsNonExpired;
    /*指示用户是启用还是禁用。无法对已禁用的用户进行身份验证。true：已启用， false：禁用 */
    private boolean enabled;

    public Long getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getPhone() {
        return phone;
    }

    public Integer getStatus() {
        return status;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }


}
